import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘国水
 * Date: 2025-06-14
 * Time: 13:47
 */
public class test {
//    public static String myToString(int[] array) {
//        String ret = "[";
//        //遍历 的时候 需要进行拼接
//        for (int i = 0; i < array.length; i++) {
//            ret += array[i];
//            if(i != array.length-1) {
//                ret += ",";
//            }
//        }
//        //加上一个]
//        ret += "]";
//        return ret;
//    }
//
//    public static void main(String[] args) {
//        int[] arr = {1,2,3,4,5,6};
//        String newArr = myToString(arr);
//        System.out.println(newArr);
//    }
//    public static void main1(String[] args) {
//        int[] array = new int[5];
//        System.out.println(array);
//        System.out.println(array[0]);
//    }
//    public static String myToString(int[] array) {
//        String ret = "[";
//        //遍历 的时候 需要进行拼接
//        for (int i = 0; i < array.length; i++) {
//            ret += array[i];
//            if(i != array.length-1) {
//                ret += ",";
//            }
//        }
//        //加上一个]
//        ret += "]";
//        return ret;
//    }
//
//    public static void main(String[] args) {
//        int[] arr = {1,2,3,4,5,6};
//        String newArr = myToString(arr);
//        System.out.println(newArr);
//    }

    public static int add(int a,int b) {
        return a+b;
    }

    public static int[] func2() {
        int a = 1;
        int b = 2;
        int[] ret = new int[]{a,b};
        return ret;
    }

    public static int[] func3() {
        return new int[]{1,2};
    }

    public static void main12(String[] args) {
        System.out.println(Arrays.toString(func3()));
    }

    public static void main11(String[] args) {
        int[] array = func3();
        String str = Arrays.toString(array);
        System.out.println(str);
    }

    public static void swap(int[] array) {
        int tmp = array[0];
        array[0] = array[1];
        array[1] = tmp;
    }
    public static void main10(String[] args) {
        int[] array = {1,2};
        System.out.println(array[0]+" " + array[1]);
        swap(array);
        System.out.println(array[0]+" " + array[1]);
    }

    public static void test1(int[] array) {
        array[0] = 99;
    }

    public static void test2(int[] array) {
        array = new int[]{100,200,300,400,500};

        array[0] = 100000;
    }

    public static void main9(String[] args) {
        int[] array = {1,2,3,4,5};
        test1(array);
        printArray(array);//输出什么？
    }

    public static void printArray(int[] array) {

        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] +" ");
        }
        System.out.println();

    }

    public static void function(int a) {

    }

    public static void main8(String[] args) {
        int[] array = {1,2,3,4,5};

        printArray(array);

        int a = 10;
        function(a);

    }

    public static void main7(String[] args) {

        int[] array2 = null;

        System.out.println(array2[2]);

    }

    public static void func() {
        int[] array1 = new int[3];
        array1[0] = 10;
        array1[1] = 20;
        array1[2] = 30;

        int[] array2 = new int[]{1,2,3,4,5};
        array2[0] = 100;
        array2[1] = 200;

        array1 = array2;
        array1[2] = 300;
        array1[3] = 400;
        array2[4] = 500;
        for (int i = 0; i < array2.length; i++) {
            System.out.println(array2[i]);
        }
    }

    public static void main6(String[] args) {
        int a = 10;
        int b = 20;

        int[] array = {1,2,3,4,5};
        System.out.println(array);

        int c = 0;
        System.out.println(c);

        int[] array2 = null;
        System.out.println(array2);
    }

    public static void main5(String[] args) {
        int[] array = {1,2,3,4,5};

        //通过数组名.length可以求当前数组的长度
       /* int len = array.length;
        System.out.println("数组的长度："+len);
*/

        for (int i = 0; i < array.length; i++) {
           /* if(i == 2) {
                sssssss
            }*/
            System.out.print(array[i]+" ");
        }
        System.out.println();
        System.out.println("=======for each======");
        for(int x : array) {
            System.out.print(x+" ");
        }
        System.out.println();

        System.out.println("=======借助工具======");

       /* String ret = Arrays.toString(array);
        System.out.println(ret);
*/
        System.out.println(Arrays.toString(array));

        /*System.out.println(array[13]);
        array[3] = 88;
        System.out.println(array[3]);*/

    }

    public static void main4(String[] args) {
        int[] array;
        array = new int[]{1,2,3,4};

        int[] array2;
        array2 = new int[5];

       /* int[] array3;
        array3 = {1,2,3,4,5}; error */

        boolean[] booleans = new boolean[3];

        String[] names = new String[3];

    }

    public static void main3(String[] args) {
        int[] array = {1,2,3,4,5};
        int[] array2 = new int[]{1,2,3,4,5};
        int arr[] = {1,2,3,4,5};
    }

    public static void main2(String[] args) {
        //动态初始化
        int[] array = new int[5];
        array[2] = 99;
        int ret = array[2];
        System.out.println(ret);
    }
    public static void main19(String[] args) {
        int[] array = new int[5];
        double[] array2 = new double[5];
        String[] array3 = new String[5];

        int a = 10;
    }

//    public static void main(String[] args) {
//        int[] array = {1,2,3,4,5,6};
//
//    }
}
